package cn.edu.ctbu.demo1.core;
import cn.edu.ctbu.demo1.exception.REnum;
import cn.edu.ctbu.demo1.vo.R;

/**
 * 对R对象就行简化
 */
public class RUtil {
    public static R success(Object object){
        R result = new R();
        result.setCode(1);
        result.setData(object);
        result.setMsg("执行成功！");

        return  result;
    }
    public static R successTeacher(Object object){
        R result = new R();
        result.setCode(2);
        result.setData(object);
        result.setMsg("执行成功！");
        return  result;
    }
    public static R successManage(Object object){
        R result = new R();
        result.setCode(3);
        result.setData(object);
        result.setMsg("执行成功！");
        return  result;
    }
    public static R  sucess(PageUtils pageUtils){
        return success(null);
    }
//    public static R successTeacher(){return success(null);}
    public static  R error(Integer code ,String msg){
        R result = new R();
        result.setCode(code);
        result.setData(null);
        result.setMsg(msg);

        return result;
    }

    public  static  R error(REnum rEnum){
        return  error(rEnum.getCode(),rEnum.getMsg());
    }


}
